#include "PrecompiledHeaderRenderer_OpenGL.h"
#include "ROpenGL.h"

/*--------------------------------------------------------------------------*/
ROpenGL* ROpenGL::instance = NULL;
glm::ivec2 ROpenGL::_resolution = glm::ivec2(800, 600);
/*--------------------------------------------------------------------------*/

ROpenGL::ROpenGL()
{
}

/*--------------------------------------------------------------------------*/

ROpenGL::~ROpenGL()
{
}

/*--------------------------------------------------------------------------*/

void ROpenGL::Init(const glm::ivec2& resolution)
{
	if (!instance)
	{
		instance = new ROpenGL();
		_resolution = resolution;

		ROpenGL::Viewport(0.0f, 0.0f, resolution.x, resolution.y);
		ROpenGL::ClearBuffers();

		InitializeCubeVao();
		InitializeFullscreenQuadVao();
		InitializeLargeSphere();
		InitializePrimitiveContainerVao();
		InitializeQuadVao();
		InitializeSmallSphere();
	}
}

/*--------------------------------------------------------------------------*/

void ROpenGL::Free()
{

	if (instance)
	{
		FreeCommonWrapper();

		delete instance;
		instance = NULL;
	}
}

/*--------------------------------------------------------------------------*/

glm::ivec2 ROpenGL::GetResolution()
{
	return _resolution;
}

/*--------------------------------------------------------------------------*/

// void ROpenGL::Init()
// {
// 	static bool isInitialized = false;
// 	AssertLogC(isInitialized == true, "OpenGL already initialized.");
//
// 	_boundTextures = new Texture*[32];
//
// 	for (uint i = 0; i < 32; ++i)
// 	{
// 		_boundTextures[i] = NULL;
// 	}
//
// 	/*--------------------------------------------------------------------------*/
//
// 	BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// 	ClearColor(vl::Pink);
// 	ClearDepth(1.0f);
// 	CullFaceEnabled(GL_TRUE);
// 	CullFaceMode(GL_BACK);
// 	FrontFace(GL_CCW);
// 	DepthFunc(GL_LEQUAL);
//
// 	/*--------------------------------------------------------------------------*/
//
// 	isInitialized = true;
// }

/*--------------------------------------------------------------------------*/

// void ROpenGL::Free()
// {
// 	delete [] _boundTextures;
//
// 	/*--------------------------------------------------------------------------*/
//
// 	AssertLogC(_framebuffersCount != 0, "There are %d Framebuffers left!", _framebuffersCount);
// 	AssertLogC(_vertexArrayCount != 0, "There are %d VertexArrays left!", _vertexArrayCount);
// }

/*--------------------------------------------------------------------------*/
